'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    const {
      INTEGER,
      DATE,
      STRING,
      BLOB,
    } = Sequelize;
    return await queryInterface.createTable('user', {
      id: {
        type: INTEGER,
        allowNull: false,
        primaryKey: true,
        autoIncrement: true,
        comment: '序号',
      },
      username: {
        type: STRING(50),
        allowNull: true,
        comment: '姓名',
      },
      password: {
        type: BLOB,
        allowNull: false,
        comment: '密码',
      },
      userimg: {
        type: STRING(100),
        allowNull: false,
        comment: '头像',
      },
      tel: {
        type: STRING(20),
        allowNull: false,
        comment: '手机号码',
      },
      email: {
        type: STRING(50),
        comment: '邮箱',
      },
      nickname: {
        type: STRING(50),
        allowNull: false,
        unique: true,
        comment: '昵称',
      },
      sex: {
        type: INTEGER(2),
        allowNull: false,
        comment: '性别',
      },
      birthday: {
        type: DATE,
        comment: '生日',
      },
      provinceaddress: {
        type: STRING(50),
        comment: '省',
      },
      cityaddress: {
        type: STRING(50),
        comment: '市',
      },
      areaaddress: {
        type: STRING(50),
        comment: '县',
      },
      hobby: {
        type: STRING(50),
        comment: '爱好',
      },
      createdDate: {
        type: DATE,
        allowNull: false,
        comment: '入库时间',
      },
      updatedDate: {
        type: DATE,
        allowNull: false,
        comment: '更新登录时间',
      },
    });
  },

  down: async queryInterface => {
    return await queryInterface.dropTable('users');
  },
};
